package qdu.edu.com.fushanf4.service.count.usertype.search2characters.count.clean;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import qdu.edu.com.fushanf4.service.count.usertype.ClassificationOfProductDescriptionsByUserTypeReducer;
import qdu.edu.com.fushanf4.utils.ConfigurationUtil;
import qdu.edu.com.fushanf4.utils.DriverUtil;

import java.io.IOException;

/**
 * 清洗非汉字字符，将其替换成\n
 *
 * 输入：/hadoop/service/count/usertype/output
 * 输出：/hadoop/service/count/usertype/search2characters/count/clean/output
 * 输出作为SplitStringAndSplicingTwoCharactersDriver类的输入
 *
 * 例如：分恢复是否会和，违法回复。开发IE哦阿海，而回顾
 * 清洗为：分恢复是否会和\n违法回复\n开发\n哦阿海\n而回顾
 *
 * 注意：可能出现这种情况，需要清理空行
 *
 * 例如：分发挥，“方式”。你就
 * 切分成：分发挥\n\n方式\n\n你就
 */
public class CleanStringDriver extends DriverUtil {
    public static void main(String[] args) throws IOException {
        CleanStringDriver cleanStringDriver = new CleanStringDriver();
        cleanStringDriver.run(args);
    }

    @Override
    public Job runJob(String[] path) throws IOException {
        Job job = ConfigurationUtil.getJob();

        job.setJarByClass(CleanStringDriver.class);
        job.setMapperClass(CleanStringMapper.class);

        job.setOutputKeyClass(NullWritable.class);
        job.setOutputValueClass(Text.class);

        assert ConfigurationUtil.setPathAndRunJob(path, job);

        return job;
    }
}
